package com.share.rest;

import com.share.domain.Student;
import com.share.service.IStudentService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
 * author:caifan
 * date:2019/7/22
 */
@RestController
@RequestMapping("/rest/student")
@Slf4j
public class StudentRest {
    @Autowired
    private IStudentService studentService;

    @RequestMapping(value = "/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public void saveStudent(@RequestBody Student student) {
        studentService.saveStudent(student);
    }

    @GetMapping(value = "/student")
    public String getStudent() {
        return "student";
    }

    @PostMapping(value = "/test")
    public String get(@RequestBody Student student) {
        log.info(ToStringBuilder.reflectionToString(student));
        return "aaa";
    }
}
